<template>
  <el-menu
    id="menuItem"
    :default-active="activeIndex"
    class="el-menu-demo"
    mode="horizontal"
    @select="handleSelect"
    background-color="#606266"
    router
  >
    <el-menu-item index="1" route="/articleinfo">首页</el-menu-item>
    <el-menu-item index="2" route="/company">公司动态</el-menu-item>
    <el-menu-item index="3" route="/excellentworks">大神风采</el-menu-item>
    <el-menu-item index="4" route="/aboutus">关于我们</el-menu-item>
    <div id="btn3">
       <el-dropdown trigger="click">
        <span class="el-dropdown-link" style="color: white">
          {{ username }}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item id="registryBtn" @click.native="outlogin"
            >注销</el-dropdown-item
          >
        </el-dropdown-menu>
      </el-dropdown>
    </div>

    <el-dialog
      title="提示"
      :visible.sync="centerDialogVisible"
      width="30%"
      center
    >
      <span>你忍心退出吗 退出可就要重新登路了哦</span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="centerDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="handleConfirmLogout">确 定</el-button>
      </span>
    </el-dialog>
  </el-menu>
</template>

<script>
import {clearToken,clearUserId } from "../../utils/auth";
export default {
  data() {
    return {
      activeIndex: "1",
      activeIndex2: "1",
      centerDialogVisible : false,
      username:localStorage.getItem(("userName"))
    };
  },
  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    },
    login(){
      this.$router.push('/login')
    },
    outlogin(){
      this.centerDialogVisible = true;
    },
    handleConfirmLogout(){
      clearToken();
      clearUserId();
      sessionStorage.setItem("token","false");
      this.$router.push("/login");
      this.centerDialogVisible = false;
    },
  },
};
</script>

<style>
.el-breadcrumb__inner {
  color: black;
}
#btn3{
  float: right;
  margin-right: 15px;
}
</style>
评论 ( 0 )